<?php
$this->breadcrumbs = array(
    'Quản trị' => array('/admin'),
    'Thành viên' => array('index'),
    'Danh sách',
);

$this->menu = array(
    array('label' => 'Danh sách user', 'url' => array('index')),
    array('label' => 'Tạo user', 'url' => array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('user-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1>Quản lý thành viên</h1>
<?php echo CHtml::link('Tìm kiếm', '#', array('class' => 'search-button')); ?>
<div class="search-form" style="display:none">
    <?php $this->renderPartial('_search', array(
    'model' => $model,
)); ?>
</div><!-- search-form -->
<?php
function getIsvalidate($value){
    $out = '';
    switch($value){
        case 1:
            $out = 'Active';
            break;
        case 2:
            $out = 'Not Active';
            break;
    }
    return $out;
}
function getRoleName($role){
    $arrRoles = Rights::getAuthItemSelectOptions(2);
    return $arrRoles[$role];
}

?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'user-grid',
    'dataProvider' => $model->search(),
    //'filter' => $model,
    'columns' => array(
        //'id',
        'username',
        //'password',
        'email',
        //'home_page',
        //'registered_time',
        array(
            'name'=>'registered_time',
            'value'=>'date("d/m/Y", $data->registered_time)',
        ),
        'display_name',
        //'status',
        //'active_code',
        array(
            'name'=>'is_validated',
            'value'=>'getIsvalidate($data->is_validated)',
        ),
        //'role',
        array(
            'name'=>'role',
            'value'=>'getRoleName($data->role)'
        ),

        array(
            'class' => 'CButtonColumn',
        ),
    ),
)); ?>
